﻿@using Presentation.Web.Admin
@{
    ViewBag.subtitle = "初始化系统权限";
    ViewBag.Title = "初始化系统权限";
}
@{
    if (Html.HasUiPermission(this.ViewContext, "init"))
    {
    <div style="margin-left: 2%; margin-top: 2%;">
        <ul>
            <li style="margin: 10px 0; list-style: none;">1、<input id="initAllPermission" type="button"
                value="初始化系统所有权限" title="系统已有的权限不会被覆盖" class="t-button" /><br />
            </li>
            <li style="margin: 10px 0; list-style: none;">2、<input id="initSuperAdminPermission"
                type="button" value="初始化超级管理员权限" title="初始化超级管理员权限" class="t-button" /><br />
            </li>
            <li style="margin: 10px 0; list-style: none;">3、<input id="initSystemUserPermission"
                type="button" value="初始化系统管理员权限" title="初始化系统管理员权限" class="t-button" /><br />
            </li>
            <li style="margin: 10px 0; list-style: none;">4、<input id="initOpenUserPermission"
                type="button" value="初始化接口用户权限" title="初始化接口用户权限" class="t-button" /><br />
            </li>
        </ul>
    </div>
    <script type="text/javascript">
        $("#initAllPermission").click(function () {
            var data = { rand: new Date() };
            $.post('/permission/initall/', data, function (res) {
                if (res.success) {
                    alert('初始化数据成功');
                }
                else {
                    alert(res.message);
                }
            });
        });

        $("#initSuperAdminPermission").click(function () {
            var data = { rand: new Date() };
            $.post('/permission/initadminpermission', data, function (res) {
                if (res.success) {
                    alert('初始化数据成功');
                }
                else {
                    alert(res.message);
                }
            });
        });

        $("#initSystemUserPermission").click(function () {
            var data = { rand: new Date() };
            $.post('/permission/initsystemuserpermission', data, function (res) {
                if (res.success) {
                    alert('初始化数据成功');
                }
                else {
                    alert(res.message);
                }
            });
        });

        $("#initOpenUserPermission").click(function () {
            var data = { rand: new Date() };
            $.post('/permission/initopenuserpermission', data, function (res) {
                if (res.success) {
                    alert('初始化数据成功');
                }
                else {
                    alert(res.message);
                }
            });
        });
    
    </script>
    }
}
